package lab3;

import org.junit.Test;
import static org.junit.Assert.*;

public class BinaryOperationTest {
    
    @Test
    public void testConstructor() {
        BinaryOperation op = new BinaryOperation(5, 3, '+');
        assertEquals(5, op.getLeftOperand());
        assertEquals(3, op.getRightOperand());
        assertEquals('+', op.getOperator());
        assertEquals(8, op.getValue());
    }
    
    @Test
    public void testAdditionOperation() {
        BinaryOperation op = new BinaryOperation();
        BinaryOperation addition = op.generateAdditionOperation();
        
        assertTrue(addition.getOperator() == '+');
        assertTrue(addition.getValue() >= 0 && addition.getValue() <= 100);
        assertTrue(addition.getLeftOperand() >= 0 && addition.getLeftOperand() <= 100);
        assertTrue(addition.getRightOperand() >= 0 && addition.getRightOperand() <= 100);
    }
    
    @Test
    public void testSubtractionOperation() {
        BinaryOperation op = new BinaryOperation();
        BinaryOperation subtraction = op.generateSubstractOperation();
        
        assertTrue(subtraction.getOperator() == '-');
        assertTrue(subtraction.getValue() >= 0 && subtraction.getValue() <= 100);
        assertTrue(subtraction.getLeftOperand() >= 0 && subtraction.getLeftOperand() <= 100);
        assertTrue(subtraction.getRightOperand() >= 0 && subtraction.getRightOperand() <= 100);
    }
    
    @Test
    public void testEquals() {
        BinaryOperation op1 = new BinaryOperation(5, 3, '+');
        BinaryOperation op2 = new BinaryOperation(5, 3, '+');
        BinaryOperation op3 = new BinaryOperation(5, 3, '-');
        BinaryOperation op4 = new BinaryOperation(6, 3, '+');
        
        assertTrue(op1.equals(op2));
        assertFalse(op1.equals(op3));
        assertFalse(op1.equals(op4));
    }
    
    @Test
    public void testToString() {
        BinaryOperation op = new BinaryOperation(5, 3, '+');
        assertEquals("5+3", op.toString());
        assertEquals("5+3=8", op.fullString());
    }
}
